<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>短信接口</title>
    <!-- 引入leancloud 存储 sdk -->
    <script src="//cdn.jsdelivr.net/npm/leancloud-storage@4.10.0/dist/av-min.js"></script>

</head>

<body>

    <button onclick="sendSms()">
        发送验证码
    </button>

    <button onclick="verySms()">
        验证验证码
    </button>
    <script>
        AV.init({
            appId: "2BCY3dkDcYQoqOC08anq98iP-MdYXbMMI",
            appKey: "qictNcJgpf33fwgs0Tzb7wGD"
        });

        function sendSms() {
            AV.Cloud.requestSmsCode({
                mobilePhoneNumber: '17344423362',
                name: '小K生鲜',
                ttl: 10 // 验证码有效时间为 10 分钟
            }).then(function () {
                // 调用成功
                console.log('发送成功')
            }, function (err) {
                // 调用失败
                console.log('发送失败',err)
            });
        }

        function verySms() {
            AV.Cloud.verifySmsCode('246064', '17344423362').then(function () {
                // 验证成功
                console.log('验证通过')
            }, function (err) {
                // 验证失败
                console.log('err', err)
            });

        }
    </script>
</body>

</html>